import request from '@/utils/http'

/**
 * 库存管理API服务
 * 参照原项目：RuoYi-WMS-VUE/src/api/wms/inventory.js
 */
export class WmsInventoryService {
  /**
   * 查询库存列表
   */
  static async list(query: Record<string, any> = {}) {
    return request.get({
      url: '/wms/inventory/list',
      params: query
    })
  }

  /**
   * 查询库存看板仓库维度列表
   */
  static async boardList(query: Record<string, any> = {}, type: string) {
    return request.get({
      url: `/wms/inventory/boardList/${type}`,
      params: query
    })
  }

  /**
   * 查询库存详细
   */
  static async detail(id: string | number) {
    return request.get({
      url: `/wms/inventory/${id}`
    })
  }

  /**
   * 新增库存
   */
  static async create(data: Record<string, any>) {
    return request.post({
      url: '/wms/inventory',
      data
    })
  }

  /**
   * 修改库存
   */
  static async update(data: Record<string, any>) {
    return request.put({
      url: '/wms/inventory',
      data
    })
  }

  /**
   * 删除库存
   */
  static async delete(id: string | number | Array<string | number>) {
    const ids = Array.isArray(id) ? id.join(',') : id
    return request.del({
      url: `/wms/inventory/${ids}`
    })
  }

  /**
   * 导出库存
   */
  static async export(query: Record<string, any> = {}) {
    return request.post({
      url: '/wms/inventory/export',
      data: query,
      responseType: 'blob'
    })
  }
}

// 为了兼容动态API系统，导出配置对象
export const inventoryApiConfig = {
  list: '/wms/inventory/list',
  boardList: '/wms/inventory/boardList',
  detail: '/wms/inventory',
  create: '/wms/inventory',
  update: '/wms/inventory',
  delete: '/wms/inventory',
  export: '/wms/inventory/export'
}

export default WmsInventoryService